package com.ry.net.system.user;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * user login auth
 */
public class AuthFilter implements Filter {
	FilterConfig config = null;

	public void init(FilterConfig config) throws ServletException {

		this.config = config;
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		// convert request andresponse as HTTP type
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse res = (HttpServletResponse) response;

		String servletPath = req.getServletPath();
//		if (servletPath.startsWith("/survey/")&&!"/survey/doSurvey.do".equals(servletPath)) {
//			
//			if (req.getSession().getAttribute("user") == null) {
//				res.sendRedirect(req.getContextPath() + "/user/toLogin.do");// 指定要跳转的页面
//				return;
//			}
//		}

		chain.doFilter(request, response);

	}

	public void destroy() {
	}

}
